<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * @var $block \Magento\Downloadable\Block\Customer\Products\ListProducts
 */
?>
<?php $_items = $block->getItems(); ?>
<?php if (count($_items)): ?>
    <div class="table-wrapper downloadable-products">
        <table id="my-downloadable-products-table" class="data table table-downloadable-products">
            <caption class="table-caption"><?php /* @escapeNotVerified */ echo __('Downloadable Products') ?></caption>
            <thead>
                <tr>
                    <th scope="col" class="col id"><?php /* @escapeNotVerified */ echo __('Order #') ?></th>
                    <th scope="col" class="col date"><?php /* @escapeNotVerified */ echo __('Date') ?></th>
                    <th scope="col" class="col title"><?php /* @escapeNotVerified */ echo __('Title') ?></th>
                    <th scope="col" class="col status"><?php /* @escapeNotVerified */ echo __('Status') ?></th>
                    <th scope="col" class="col remaining"><?php /* @escapeNotVerified */ echo __('Remaining Downloads') ?></th>
                </tr>
            </thead>
            <tbody>
            <?php foreach ($_items as $_item): ?>
                <tr>
                    <td data-th="<?php echo $block->escapeHtml(__('Order #')) ?>" class="col id">
                        <a href="<?php /* @escapeNotVerified */ echo $block->getOrderViewUrl($_item->getPurchased()->getOrderId()) ?>"
                            title="<?php echo $block->escapeHtml(__('View Order')) ?>">
                            <?php /* @escapeNotVerified */ echo $_item->getPurchased()->getOrderIncrementId() ?>
                        </a>
                    </td>
                    <td data-th="<?php echo $block->escapeHtml(__('Date')) ?>" class="col date"><?php /* @escapeNotVerified */ echo $block->formatDate($_item->getPurchased()->getCreatedAt()) ?></td>
                    <td data-th="<?php echo $block->escapeHtml(__('Title')) ?>" class="col title">
                        <strong class="product-name"><?php echo $block->escapeHtml($_item->getPurchased()->getProductName()) ?></strong>
                        <a href="<?php /* @escapeNotVerified */ echo $block->getDownloadUrl($_item) ?>" title="<?php echo $block->escapeHtml(__('Start Download')) ?>" class="action download" <?php echo $block->getIsOpenInNewWindow() ? 'onclick="this.target=\'_blank\'"' : ''; ?>><?php echo $block->escapeHtml($_item->getLinkTitle()) ?></a>
                    </td>
                    <td data-th="<?php echo $block->escapeHtml(__('Status')) ?>" class="col status"><?php /* @escapeNotVerified */ echo __(ucfirst($_item->getStatus())) ?></td>
                    <td data-th="<?php echo $block->escapeHtml(__('Remaining Downloads')) ?>" class="col remaining"><?php /* @escapeNotVerified */ echo $block->getRemainingDownloads($_item) ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
    <?php if ($block->getChildHtml('pager')): ?>
        <div class="toolbar downloadable-products-toolbar bottom">
            <?php echo $block->getChildHtml('pager'); ?>
        </div>
    <?php endif; ?>
<?php else: ?>
    <div class="message info empty"><span><?php /* @escapeNotVerified */ echo __('You have not purchased any downloadable products yet.'); ?></span></div>
<?php endif; ?>

<div class="actions-toolbar">
    <div class="secondary">
        <a href="<?php echo $block->escapeUrl($block->getBackUrl()) ?>" class="action back">
            <span><?php /* @escapeNotVerified */ echo __('Back') ?></span>
        </a>
    </div>
</div>
